home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / text / DefaultCaret$UpdateHandler.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  3.3 KB  |  134 lines

  1. package javax.swing.text;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.beans.PropertyChangeEvent;
  6. import java.beans.PropertyChangeListener;
  7. import javax.swing.SwingUtilities;
  8. import javax.swing.event.DocumentEvent;
  9. import javax.swing.event.DocumentListener;
  10. import javax.swing.text.Position.Bias;
  11.  
  12. class DefaultCaret$UpdateHandler implements PropertyChangeListener, DocumentListener, ActionListener {
  13.    // $FF: synthetic field
  14.    private final DefaultCaret this$0;
  15.  
  16.    DefaultCaret$UpdateHandler(DefaultCaret var1) {
  17.       this.this$0 = var1;
  18.    }
  19.  
  20.    public void actionPerformed(ActionEvent var1) {
  21.       if (this.this$0.visible || this.this$0.width != 0 && this.this$0.height != 0) {
  22.          this.this$0.visible ^= true;
  23.          this.this$0.repaint();
  24.       } else {
  25.          this.this$0.setVisible(true);
  26.       }
  27.  
  28.    }
  29.  
  30.    public void changedUpdate(DocumentEvent var1) {
  31.    }
  32.  
  33.    public void insertUpdate(DocumentEvent var1) {
  34.       if (this.this$0.async || SwingUtilities.isEventDispatchThread()) {
  35.          int var2 = 0;
  36.          int var3 = var1.getOffset();
  37.          int var4 = var1.getLength();
  38.          if (this.this$0.dot >= var3) {
  39.             var2 = var4;
  40.          }
  41.  
  42.          if (this.this$0.mark >= var3) {
  43.             DefaultCaret var10000 = this.this$0;
  44.             var10000.mark += var4;
  45.          }
  46.  
  47.          if (var2 != 0) {
  48.             if (this.this$0.dot == var3) {
  49.                Document var5 = this.this$0.component.getDocument();
  50.                int var6 = this.this$0.dot + var2;
  51.  
  52.                boolean var7;
  53.                try {
  54.                   var7 = var5.getText(var6 - 1, 1).equals("\n");
  55.                } catch (BadLocationException var8) {
  56.                   var7 = false;
  57.                }
  58.  
  59.                if (var7) {
  60.                   this.this$0.changeCaretPosition(var6, Bias.Forward);
  61.                } else {
  62.                   this.this$0.changeCaretPosition(var6, Bias.Backward);
  63.                }
  64.             } else {
  65.                this.this$0.changeCaretPosition(this.this$0.dot + var2, this.this$0.dotBias);
  66.             }
  67.          }
  68.       }
  69.  
  70.    }
  71.  
  72.    public void propertyChange(PropertyChangeEvent var1) {
  73.       Object var2 = var1.getOldValue();
  74.       Object var3 = var1.getNewValue();
  75.       if (var2 instanceof Document || var3 instanceof Document) {
  76.          this.this$0.setDot(0);
  77.          if (var2 != null) {
  78.             ((Document)var2).removeDocumentListener(this);
  79.          }
  80.  
  81.          if (var3 != null) {
  82.             ((Document)var3).addDocumentListener(this);
  83.          }
  84.       }
  85.  
  86.    }
  87.  
  88.    public void removeUpdate(DocumentEvent var1) {
  89.       if (this.this$0.async || SwingUtilities.isEventDispatchThread()) {
  90.          int var2 = 0;
  91.          int var3 = var1.getOffset();
  92.          int var4 = var3 + var1.getLength();
  93.          boolean var5 = false;
  94.          if (this.this$0.dot >= var4) {
  95.             var2 = var4 - var3;
  96.             if (this.this$0.dot == var4) {
  97.                var5 = true;
  98.             }
  99.          } else if (this.this$0.dot >= var3) {
  100.             var2 = this.this$0.dot - var3;
  101.             var5 = true;
  102.          }
  103.  
  104.          boolean var6 = false;
  105.          if (this.this$0.mark >= var4) {
  106.             DefaultCaret var10000 = this.this$0;
  107.             var10000.mark -= var4 - var3;
  108.             if (this.this$0.mark == var4) {
  109.                var6 = true;
  110.             }
  111.          } else if (this.this$0.mark >= var3) {
  112.             this.this$0.mark = var3;
  113.             var6 = true;
  114.          }
  115.  
  116.          if (this.this$0.mark == this.this$0.dot - var2) {
  117.             this.this$0.setDot(this.this$0.dot - var2, this.this$0.guessBiasForOffset(this.this$0.dot - var2, this.this$0.dotBias, this.this$0.dotLTR));
  118.          } else {
  119.             if (var5) {
  120.                this.this$0.dotBias = this.this$0.guessBiasForOffset(this.this$0.dot - var2, this.this$0.dotBias, this.this$0.dotLTR);
  121.             }
  122.  
  123.             if (var6) {
  124.                this.this$0.markBias = this.this$0.guessBiasForOffset(this.this$0.mark, this.this$0.markBias, this.this$0.markLTR);
  125.             }
  126.  
  127.             this.this$0.changeCaretPosition(this.this$0.dot - var2, this.this$0.dotBias);
  128.             this.this$0.markLTR = this.this$0.isPositionLTR(this.this$0.mark, this.this$0.markBias);
  129.          }
  130.       }
  131.  
  132.    }
  133. }
  134.